#!/bin/sh
# Hide the mouse after 3 seconds inactivity
unclutter -idle 3 &

# Start programs
dwmblocks &

userresources=$XDG_CONFIG_HOME/x11/xresources
usermodmap=$XDG_CONFIG_HOME/x11/xmodmap
transmission-daemon &
xrandr --dpi 96         # Set DPI. User may want to use a larger number for larger screens.
setbg ${XDG_DATA_HOME:-$HOME/.local/share}/pictures/walls &           # set the background with the `setbg` script
remaps &        # run the remaps script, switching caps/esc and more; check it for more info

# merge in defaults and keymaps
# xrdb -merge "$userresources"
xmodmap "$usermodmap"

# Other things
export SSH_AUTH_SOCK
export XDG_SESSION_TYPE=X11

xrandr --auto
xrandr --dpi 96

# Log DWM's output
exec dwm > ~/.local/share/dwm/log

keynav daemonize # control the mouse pointer with your keyboard

if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile" ]; then
	. "${XDG_CONFIG_HOME:-$HOME/.config}/x11/xprofile"
#else
#	#. "$HOME/.xprofile"
fi


autostart="mpd xcompmgr dunst unclutter pipewire transmission-daemon"

for program in $autostart; do
        pidof -s "$program" || "$program" &
done >/dev/null 2>&1

idlesleep 5 slock loginctl suspend & # sleep
# idlesleep 5 doas zzz -H && slock & # hibernate


# Ensure that xrdb has finished running before moving on to start the WM/DE.
[ -n "$xrdbpid" ] && wait "$xrdbpid"

# Log DWM's output
ssh-agent dwm > ${XDG_DATA_HOME:-$HOME/.local/share}/dwm/log
